Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Container Suite
OpenDoc Storage System is designed to work with multiple container suites. The Bento Container Suite is going to be shipped with OpenDoc 1.0. However, other vendors (besides the platform implementor) may want to provide alternate container suites.
Creating a container
In order to create a container, the client has to call the following ODStorageSystem method:
ODContainer CreateContainer(in ODContainerType containerType, in ODContainerID id);
The first parameter of the method identifies the type of the container. In order to create a Bento file container, the in parameter needs to be kODBentoFileContainer and the second parameter the FSSpec of the file where the container is to be created.
This binding is done at runtime. OpenDoc Binding scans the Editors folder(s) for container suite libraries. Each container suite library contains a 'nmap' resource which lists the type(s) of containers that the container suite can create. OpenDoc Binding then caches this information and uses it to determine which container suite library to use when ODStorageSystem::CreateContainer is called.
The following is the 'nmap' resource of the Bento Container Suite as defined in a private resource file:
// kODNameMappings, kODContainerSuite and kODIsAnISOString are defined by OpenDoc.
// They can be found in StdDef.r.
resource kODNameMappings (kNMAPid1) {
kODContainerSuite,
{ /* array Types: 2 elements */
/* [1] */
kODBentoFileContainer,
kODIsAnISOString {
kODFileContainerID
},
/* [2] */
kODBentoMemoryContainer,
kODIsAnISOString {
kODMemoryContainerID
}
};
As it is outlined in the resource, the Bento Container Suite can create two kinds of containers -- file and memory.
Other container suite providers need to include this 'nmap' resource into their container suite libraries. Otherwise, their container suite will never be bound and created.
Acquiring a container
The process of acquiring a container is almost the same as creating a container. The following ODStorageSystem method is used to acquire a previously created container:
ODContainer AcquireContainer(in ODContainerType containerType, in ODContainerID id);
The same process takes place to bind the container suite library for the container type supplied.
Default container type
In OpenDoc 1.0, the default container types are interpreted as the Bento container types. Therefore, supplying kODDefaultFileContainer to AcquireContainer or CreateContainer will result in a Bento file container being instantiated. Similarly, supplying kODDefaultMemoryContainer to the same methods will result in a Bento memory container being instantiated.